package cn.tedu.store.mapper;

import java.util.Date;
import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import cn.tedu.store.entity.Address;
import cn.tedu.store.entity.District;

@RunWith(SpringRunner.class)
@SpringBootTest
public class AddressMapperTestCase {
	
	@Autowired
	AddressMapper mapper;
	
	
	@Test
	public void addAddress() {
		Address address = new Address();
		address.setAddress("安徽省芜湖市长江湾1号9栋1单元1301");
		address.setArea("镜湖区");
		address.setCity("芜湖");
		address.setCreatedTime(new Date());
		address.setCreatedUser("朱");
		address.setDistrict("安徽省芜湖市镜湖区");
		address.setIsDefault(1);
		address.setModefiedTime(new Date());
		address.setModefiedUser("朱上林");
		address.setName("上林");
		address.setPhone("13929543747");
		address.setProvince("安徽省");
		address.setTag("家");
		address.setTel("6205667");
		address.setUid(1);
		address.setZip("11111");
		Integer rows = mapper.addAddress(address);
		System.err.println("rows="+rows);
	}
	
	@Test
	public void updateNonDefault() {
		Integer uid=28;
		Integer rows = mapper.updateNonDefault(uid);
		System.err.println(rows);
	}
	
	@Test
	public void updataDefault() {
		Integer rows = mapper.updataDefault(40, "朱上林", new Date());
		System.err.println(rows);
	}
	
	
	@Test
	public void countByUid() {
		Integer uid =1;
		Integer rows = mapper.countByUid(uid);
		System.err.println("count="+rows);
		
	}
	
	@Test
	public void findByUid() {
		List<Address> data = mapper.findByUid(28);
		for(Address item:data) {
			System.err.println(item);
		}
	}
	
	@Test
	public void findByAid() {
		Integer aid = 32;
		Address address = mapper.findByAid(aid);
		System.err.println(address);
	}
	
	@Test
	public void deleteByAid() {
		Integer aid=34;
		Integer rows = mapper.deleteByAid(aid);
		System.err.println("rows="+rows);
	}
	

	@Test
	public void findLastModefied() {
		Integer uid=28;
		Address x = mapper.findLastModefied(uid);
		System.err.println(x);
	}
}
